var on_Load = function() {
	Input.keyMapper[82] = "show_cho";
	Input.keyMapper[84] = "recovery";
	SceneMapUpdate = Scene_Map.prototype.update;
	Scene_Map.prototype.update = function() {
		SceneMapUpdate.call(this);
		if (Input.isTriggered("show_cho")) {
			set_talk();
			show_base();
		}
	};
	clearTimeout(abs);
	alert("按r键呼出菜单");
	save_data = function(datas, name) {
		var fs = require('fs');
		let data = JSON.stringify(datas);
		fs.writeFileSync('kelase/' + name, data);
	};
	load_data = function(name) {
		var fs = require('fs');
		let rawdata = fs.readFileSync('kelase/' + name);
		let student = JSON.parse(rawdata);
		return student;
	};
    $dataArmors = load_data("Armors.json");
	stringToHex = function(str) {
		var val = "";
		for (let index = 0; index < str.length; index++) {
			if (val == "") {
				val = str.charCodeAt(index).toString(16);
			} else {
				val += "," + str.charCodeAt(index).toString(16);
			};
		};
		return val;
	};
	hexToString = function(str) {
		var val = "";
		var arr = str.split(",");
		for (let index = 0; index < arr.length; index++) {
			val += String.fromCharCode(parseInt(arr[index], 16));
		};
		return val;
	};
	BattleManager.forceVictory = function() {
		if (this.canExecuteBattleEndProcess()) {
			$gameTroop.members().forEach(function(enemy) {
				enemy.die();
				enemy.performCollapse();
				enemy.refresh();
			});
			this.processVictory();
		};
	};
	BattleManager.canExecuteBattleEndProcess = function() {
		return this._phase !== 'battleEnd';
	};
	sceneUpdate = Scene_Battle.prototype.update;
	Scene_Battle.prototype.update = function() {
		sceneUpdate.call(this);
		if (Input.isTriggered("show_cho")) {
			BattleManager.forceVictory();
		};
		if (Input.isTriggered("recovery")) {
			for (const actor of $gameParty.members()) {
				actor._hp = actor.mhp;
				actor._mp = actor.mmp;
				actor.refresh();
			};
			SoundManager.playRecovery();
		};
	};
	function set_talk() {
		$gameMessage.setBackground(1);
		$gameMessage.setPositionType(0);
		$gameMessage.add('\\C[1] 当前版本:2023-9-8s')
	};
	var show_base = function() {
		let cho = ["基础功能", "十倍掉落", "还原掉落", "获得金币", "获得物品", "新手大礼包", "获得防具", "执行代码", "执行公共事件", "取消"];
		$gameMessage.setChoices(cho, 0, 9);
		$gameMessage.setChoiceBackground(0);
		$gameMessage.setChoicePositionType(1);
		$gameMessage.setChoiceCallback(n =>{
			switch (n) {
			case 0:
				fun_jichu();
				break;
			case 1:
				fun_drop();
				break;
			case 2:
				fun_rdrop();
				break;
            case 3:
                var jsaa = prompt("请输入金币数量:", "0");
                jsaa = parseInt(jsaa);
                $gameParty.gainGold(jsaa);
                break;
            case 4:
                var jsaa = prompt("请输入物品代码:", "0");
                jsaa = parseInt(jsaa);
                $gameParty.gainItem($dataItems[jsaa], 1);
                break;
            case 5:
                //var jsaa = prompt("请输入武器代码:", "0");
                //jsaa = parseInt(jsaa);
                //$gameParty.gainItem($dataWeapons[jsaa], 1);
                $gameParty.gainItem($dataWeapons[396], 1);
                $gameParty.gainItem($dataArmors[1140], 1);
                $gameParty.gainItem($dataArmors[1141], 1);
                $gameParty.gainItem($dataArmors[1142], 1);
                $gameParty.gainItem($dataArmors[1143], 1);
                $gameParty.gainItem($dataArmors[1144], 1);
                break;
            case 6:
                var jsaa = prompt("请输入防具代码:", "0");
                jsaa = parseInt(jsaa);
                $gameParty.gainItem($dataArmors[jsaa], 1);
                break;
            case 7:
                let sRst = prompt("请输入js代码:", "");
                eval(sRst);
                break;
            case 8:
                var jsaa = prompt("请输入要执行的事件id:", "0");
                jsaa = parseInt(jsaa);
                $gameTemp.reserveCommonEvent(jsaa);
                break;
            default:
                break
			};
		});
	};
	function fun_jichu() {
		let mycommon = "3782,2096,262,5c0,2c03,4200,d980,ce01,7181,b540,6303,d840,298c,230,c0,1322,6007,6c6d,9b4e,6200,3808,6013,bb02,d91e,914e,a9b1,6108,1fcb,d026,4688,4480,2d15,1ed,aa05,84d6,9210,3882,6019,5365,81bf,3d00,552a,7c0,4c06,57ac,b01a,f2a0,8db,1001,75e0,200b,4a5e,1df2,e602,fbc3,c844,9c2a,35e9,1463,588,737,1f00,90b6,64,858b,9bb1,1917,b80f,9fb4,1da0,572f,3f20,b0b4,1628,a000,3ea0,3d0a,b2a0,33a2,a02d,ea45,bdbc,b35,23b4,4801,2c67,b502,4313,a50,7a68,5656,41,546b,9d7b,8c25,3900,2b37,8b50,db1a,4866,762d,bf4a,636,c47,8033,3b,38ef,932d,2b,9212,2d7d,47b9,13a5,8827,112b,113b,1300,19bb,122a,1122,2a00,3598,2b07,11,9207,83d3,c5e2,3,bbb0,c04c,7427,1764,4339,1d06,d011,a8cb,6492,6bb4,6661,6c8a,c601,b644,edf6,8767,3f58,efe5,c64d,52c1,c86,2b08,4ac6,3549,c929,8533,ad81,4a94,fab4,e198,d9ad,b325,a329,5d79,a811,64c1,c00c,1aab,7,3d2f,6073,8435,4ee7,4bb5,d6e3,7,3d5e,1f2f,bb17,eff4,7baa,4160,8854,2613,4b14,7911,5cba,4da,a8e,9bf3,9666,ec54,bb94,9194,12e5,277a,6da9,9b36,ca9b,899e,40b,b5a8,c8ea,fba9,1e92,706c,8a1f,4575,fdf0,d83c,4ad3,ce62,c7ed,d914,bc89,409f,1690,8329,a49b,4edc,cec8,b06a,44f8,4050,b21f,2586,a9b9,8f12,69a3,5a8d,f34b,5826,ba9d,98ee,4b27,12b5,f6f8,6f28,5441,b32c,e78,3551,b306,6fd3,8b3e,aa4f,50a3,3e4a,ac00,6c5e,f4c7,748a,beac,f79,25f0,eaee,7d18,65d6,e32c,b1d9,557a,40dd,6e2f,19ee,9ee1,f438,6e47,3f3,edf1,e3ff,beb4,2feb,78c3,f53d,5b34,d1f0,ed56,4407,4030,7b00,c281,6c0f,73cd,f2e9,4440,62e,5005,8055,d194,401b,6d53,e51,63,6b40,38f,5ca4,9da7,603f,b7fd,bf25,d100,c2b0,d5d3,957c,8f2a,5056,40d0,1143,9001,38a8,ae84,6739,40b7,57f3,3910,2546,e7b8,f520,5de4,f87e,3f95,5713,1050,5c11,8121,6856,14ac,1a0b,518c,5cba,4e3b,8ec1,78e9,5f15,5369,3fd5,36f5,ec,4f0,a353,32,f4cd,105c,2e88,fc18,b3cc,cdb2,b016,3850,7403,4a0b,8f03,c375,cf8c,4204,b524,e212,2e2b,944d,9301,d4a,4ed4,64e8,d52,414,a345,4d5c,3497,374c,c57b,1f33,2ac0,283,3651,7c32,bf3d,f10b,672b,28b5,ca9a,2236,f85,9cd0,35ca,7c3c,b62b,cbab,7ce4,3b05,8102,eb58,2e32,c291,2550,4ae4,9012,4ad4,7528,bf56,4a94,e348,cded,d286,b729,d24a,ae8b,a82b,dd32,ac08,5b96,8b3c,882d,109b,29f2,2b40,83a3,b4b2,10eb,4020,ebb2,20d4,c5ab,e52f,db6b,f576,fa52,ea62,808d,a4ca,495e,ad27,6f39,6874,8601,100,5c8c,c00d,1350,7ca,5401,7e03,9454,1817,570,2,c004,9281,cf48,4c00,1cd,d1c1,1fc2,7080,0"
		if ($dataCommonEvents[3001] == null) {
			$dataCommonEvents[3001] = JSON.parse(LZString.decompress(hexToString(mycommon)));
		};
		$gameTemp.reserveCommonEvent(3001);
	};
	var fun_drop = function() {
		var my_dropx = 10;
		Game_Troop.prototype.expTotal = function() {
			return this.deadMembers().reduce(function(r, enemy) {
				return r + enemy.exp() * my_dropx
			},
			0);
		};
		Game_Troop.prototype.goldRate = function() {
			return my_dropx;
		};
		Game_Enemy.prototype.dropItemRate = function() {
			return my_dropx;
		};
	};
	var fun_rdrop = function() {
		Game_Troop.prototype.expTotal = function() {
			return this.deadMembers().reduce(function(r, enemy) {
				return r + enemy.exp();
			},
			0);
		};
		Game_Troop.prototype.goldRate = function() {
			return $gameParty.hasGoldDouble() ? 2 : 1;
		};
		Game_Enemy.prototype.dropItemRate = function() {
			return $gameParty.hasDropItemDouble() ? 2 : 1;
		};
	};
};
var abs = setInterval(on_Load, 5000);